local skel = fk.CreateSkill {
  name = "rmt__xiuchou",
  tags = {Skill.Hidden},
}

Fk:loadTranslationTable{
  ["rmt__xiuchou"] = "袖雠",
  [":rmt__xiuchou"] = "隐匿技，你登场后，你须弃置全部手牌，然后对一名角色造成1点伤害。当你对一名角色造成致命伤害时，"..
  "<a href='enter_hidden_href'>进入隐匿状态</a>。",

  ["#rmt__xiuchou-choose"] = "袖雠：对一名角色造成1点伤害",

  ["$rmt__xiuchou1"] = "今者同赴国难，义在必行！",
  ["$rmt__xiuchou2"] = "《诗》云：无言不酬、无德不报。此之谓也。",
}

local DIY = require "packages.diy_utility.diy_utility"
local U = require "packages.utility.utility"

skel:addEffect(U.GeneralAppeared, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasShownSkill(skel.name) then
      return not player:isKongcheng()
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local n = #table.filter(player:getCardIds("h"), function (id)
      return not player:prohibitDiscard(id)
    end)
    room:setPlayerMark(player, skel.name, n)
    player:throwAllCards("h")
    if player.dead then return end
    local tos = room:askToChoosePlayers(player, { targets = room.alive_players, min_num = 1, max_num = 1,
    prompt = "#rmt__xiuchou-choose", skill_name = skel.name, cancelable = false})
    room:damage{
      from = player,
      to = tos[1],
      damage = 1,
      skillName = skel.name,
    }
  end,
})

skel:addEffect(fk.DamageCaused, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasShownSkill(skel.name) then
      return data.damage >= (data.to.hp + data.to.shield) and player:getMark("__hidden_general") == 0 and player:getMark("__hidden_deputy") == 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    DIY.enterHidden(player)
  end,
})

return skel
